//
//  SEGSquareViewModel.m
//  Commom
//
//  Created by 乔杨 on 2019/8/20.
//

#import "SEGSquareViewModel.h"
#import <objc/runtime.h>

@implementation SEGSquareViewModel

-(instancetype)init{
    if (self == [super init]) {
        _banner = @"";
        _content = @"";
        _browseCount = @"";
        _title = @"";
        _picture = @"";
        _tag = @"";
        _objId = @"";
        _label = @"";
        _pgcType = @"";
        _objType = @"";
    }
    return self;
}
- (void)encodeWithCoder:(NSCoder *)encoder
{
    unsigned int count = 0;
    objc_property_t *propertes = class_copyPropertyList([self class], &count);
    for (int i=0; i<count; i++) {
        const char *propertyName = property_getName(propertes[i]);
        NSString *name = [NSString stringWithUTF8String:propertyName];
        id value = [self valueForKey:name];
        [encoder encodeObject:(value)?value:@"" forKey:name];
    }
}

- (id)initWithCoder:(NSCoder *)decoder
{
    if (self = [super init]) {
        unsigned int count =0;
        objc_property_t *propertes = class_copyPropertyList([self class], &count);
        for (int i = 0; i < count; i++) {
            const char *propertyName = property_getName(propertes[i]);
            NSString *name = [NSString stringWithUTF8String:propertyName];
            id value = [decoder decodeObjectForKey:name];
            [self setValue:(value)?value:@"" forKey:name];
        }
        
    }
    return self;
}
@end
